﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace e_yayincilik_webproject
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
    public class Service1 : IService1
    {


        //////////////////////////////////////////////////////////////////////////////////////////////////
        //Makale

        public List<DBclass.MakaleDBTO> OnaylananMakaleListele()
        {
            EYAYINCILIK_DBEntities entities = new EYAYINCILIK_DBEntities();
            //  var res = from r in entities.Makalelers select r;
            var sec = from customer in entities.Makalelers
                      join order in entities.MakalePathDurums
                      on customer.MakaleID equals order.MakaleID
                      select new Makaleler
                      {
                          BilimTuruID = customer.BilimTuruID,
                          DergidekiSira = customer.DergidekiSira,
                          DergiID = customer.DergiID,
                          KategoriID = customer.KategoriID,
                          Kaynaklar = customer.Kaynaklar,
                          MakaleAdi = customer.MakaleAdi,
                          MakaleID = customer.MakaleID,
                          YayinTarihi = customer.YayinTarihi,
                          YazarID = customer.YazarID,
                          YazimTarihi = customer.YazimTarihi
                      };
            List<DBclass.MakaleDBTO> abc = sec.ToList().ConvertAll(new Converter<Makaleler, DBclass.MakaleDBTO>(Converter.Convert_Makale_TO_MakaleDBTO));
            return abc;
        }

        public DBclass.MakaleDBTO MakaleBul(string makaleId)
        {
            EYAYINCILIK_DBEntities entities = new EYAYINCILIK_DBEntities();
            Makaleler res = (from r in entities.Makalelers where r.MakaleID == makaleId select r).First();
            return Converter.Convert_Makale_TO_MakaleDBTO(res);
        }

        public void MakaleEkle(DBclass.MakaleDBTO obj, DBclass.MakalePathDurumuDBTO obj2)
        {
            EYAYINCILIK_DBEntities entities = new EYAYINCILIK_DBEntities();
            Makaleler insertingobject = Converter.Convert_MakaleDBTO_TO_Makele(obj);
            insertingobject.BilimTuruID = obj.BilimTuruID;
            insertingobject.DergidekiSira = obj.DergidekiSira;
            insertingobject.DergiID = obj.DergiID;
            insertingobject.KategoriID = obj.KategoriID;
            insertingobject.Kaynaklar = obj.Kaynaklar;
            insertingobject.MakaleAdi = obj.MakaleAdi;
            insertingobject.MakaleID = obj.MakaleId;
            insertingobject.YayinTarihi = obj.YayinTarihi;
            insertingobject.YazarID = obj.YazarId;
            insertingobject.YazimTarihi = obj.YazimTarihi;
            entities.AddToMakalelers(insertingobject);






            entities.SaveChanges();
        }

        public void MakaleGuncelle(DBclass.MakaleDBTO obj, DBclass.MakalePathDurumuDBTO obj2)
        {

        }

        public void MakaleSil(string MakaleId)
        {

        }

        //////////////////////////////////////////////////////////////////////////////////////////////////
        //Dergi

        public List<DBclass.DergiDBTO> DergiListele()
        {

            return null;

        }


        public DBclass.DergiDBTO DergiBul(string dergiId)
        {

            return null;
        }

        public void DergiEkle(DBclass.DergiDBTO obj)
        {
        }


        public void DergiGuncelle(DBclass.DergiDBTO obj)
        {
        }

        public void DergiSil(string dergiId)
        {

        }

        //////////////////////////////////////////////////////////////////////////////////////////////////
        //Kategori 


        public List<DBclass.KategoriDBTO> KategoriListele()
        {

            return null;
        }

        public DBclass.KategoriDBTO KategoriBul(string kategoriId)
        {
            return null;
        }

        public void KategoriEkle(DBclass.KategoriDBTO obj)
        {
        }

        public void KategoriGuncelle(DBclass.KategoriDBTO obj)
        {
        }

        public void KategoriSil(string KategoriId)
        {
        }

        //////////////////////////////////////////////////////////////////////////////////////////////////
        //BilimDali


        public List<DBclass.BilimTuruDBTO> BilimTuruListele()
        {

            return null;
        }

        public DBclass.BilimTuruDBTO BilimTuruBul(string bilimTuruId)
        {

            return null;
        }

        public void BilimDaliEkle(DBclass.BilimTuruDBTO obj)
        {
        }

        public void BilimDaliGuncelle(DBclass.BilimTuruDBTO obj)
        {
        }

        public void BilimDaliSil(string bilimDaliId)
        {
        }

        //////////////////////////////////////////////////////////////////////////////////////////////////
        //Kullanici

        public void KullaniciEkle(DBclass.KullaniciDBTO obj)
        {
        }

        public void KullaniciGuncelle(DBclass.KullaniciDBTO obj)
        {
        }

        public void KullaniciAtama(DBclass.KullaniciDBTO obj, string sistemdekiRolu)
        {
        }

        public void KullaniciSil(string KullaniciId, string sistemdekiRolu)
        {


        }

        public List<DBclass.KullaniciDBTO> KullaniciListele()
        {
            return null;
        }

        public List<DBclass.HakemDBTO> HakemListele()
        {
            return null;
        }

        public List<DBclass.YazarDBTO> YazarListele()
        {
            return null;
        }

        public DBclass.KullaniciDBTO KullaniciBul(string kullaniciId)
        {

            return null;
        }

        //////////////////////////////////////////////////////////////////////////////////////////////////
        //Anket
        public void AnketEkle(DBclass.AnketDBTO obj)
        {
        }

        public void AnketGuncelle(DBclass.AnketDBTO obj)
        {
        }

        public void AnketSil(string AnketId)
        {
        }

        public List<DBclass.AnketDBTO> AnketListele()
        {
            return null;
        }

        public DBclass.AnketDBTO AnketBul(string anketId)
        {
            return null;
        }

        //////////////////////////////////////////////////////////////////////////////////////////////////




        /*public Makaleler FindMakale(string makaleId){
            EYAYINCILIK_DBEntities ent = new EYAYINCILIK_DBEntities();
            Makaleler res = (from r in ent.Makaleler where r.MakaleID == makaleId select r).First();
            return res;
        }

      
        public List<DBclass.MakaleDBTO> AllYuklenenMakale(){
            return null;
        }
        public DBclass.DergiDBTO FindDergi(string dergiId)
        {
            return null;
        }
         public List<DBclass.DergiDBTO> AllDergi(){
             return null;
        }
      
         public void InsertMakale(DBclass.MakaleDBTO obj){

        }
    
         public void UpdateMakale(DBclass.MakaleDBTO obj){
          

         }
          /*
         public YayinMakaleDBTO FindYayinlananMakale(string yayinMakaleId)
         {
             _ent = new Entities4();
             YayinMakale res = (from r in _ent.YayinMakales where r.YayinMakaleId == yayinMakaleId select r).First();
             return Converter.Convert_YayinMakale_TO_YayinMakaleDBTO(res);
         }

         public DergiDBTO FindDergi(string dergiId)
         {
             _ent = new Entities4();
             Dergi res = (from r in _ent.Dergis where r.DergiId == dergiId select r).First();
             return Converter.Convert_Dergi_TO_DergiDBTO(res);
         }

         public void InsertMakale(MakaleDBTO obj)
         {
             _ent = new Entities4();
             Makale insertingobject = Converter.Convert_MakaleDBTO_TO_Makale(obj);
             insertingobject.Makale_Path = obj.Makale_Path;
             insertingobject.Makale_uzanti = obj.Makale_uzanti;
             insertingobject.YazarId = obj.YazarId;
             insertingobject.MakaleId = obj.MakaleId;
             _ent.AddToMakales(insertingobject);
             _ent.SaveChanges();
             //  _ent.AcceptAllChanges();
         }

         public void UpdateMakale(MakaleDBTO obj)
         {
             _ent = new Entities4();
             Makale res = (from r in _ent.Makales where r.MakaleId == obj.MakaleId select r).First();
             //Makale insertingobject = Converter.Convert_MakaleDBTO_TO_Makale(obj);
             res.Makale_uzanti = obj.Makale_uzanti;
             res.Makale_Path = obj.Makale_Path;
             _ent.SaveChanges();
         }

         public List<YayinMakaleDBTO> AllYayinlananMakale()
         {
             _ent = new Entities4();
             var res = from r in _ent.YayinMakales select r;
             List<YayinMakaleDBTO> abc = res.ToList().ConvertAll(new Converter<YayinMakale, YayinMakaleDBTO>(Converter.Convert_YayinMakale_TO_YayinMakaleDBTO));
             return abc;
         }

         public List<MakaleDBTO> AllYuklenenMakale()
         {
             _ent = new Entities4();
             var res = from r in _ent.Makales select r;
             List<MakaleDBTO> abc = res.ToList().ConvertAll(new Converter<Makale, MakaleDBTO>(Converter.Convert_Makale_TO_MakaleDBTO));
             return abc;
         }


         public List<DergiDBTO> AllDergi()
         {
          
         }
  */
    }
}
